#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 1e5 + 10;

int n,sg[N];
ll f[210],t[210];

int main() {
#ifndef ONLINE_JUDGE
	//	freopen("1.in","r",stdin);
#endif
	n = in; sg[0] = 0; int mx = 0;
	for(int i = 1;i <= n;i++) {
		vec pot;
		for(int j = 1;j * j <= i;j++) {
			pot.pb(sg[i - j * j]);
		}
		sort(pot.begin(),pot.end()); pot.resize(unique(pot.begin(),pot.end()) - pot.begin()); pot.push_back(pot.size() + 1);
		for(int j = 0;j < pot.size();j++) if(pot[j] != j) { sg[i] = j; break; }
		mx = max(mx,sg[i]);
	}
	ll ans = 0; int o = 0;
	for(int i = n;i >= 0;i--) {
		t[sg[i]]++; for(int j = 0;j <= mx << 1;j++) f[j ^ sg[i]] += t[j]; ans += f[sg[i]];
	}
	cout << ans << endl;
	return 0;
}
